diff --git a/runtime/sema/type.go b/runtime/sema/type.go index 720d2b4846..caddea0a40 100644 --- a/runtime/sema/type.go +++ b/runtime/sema/type.go @@ -6175,12 +6175,6 @@ func checkSubTypeWithoutEquality(subType Type, superType Type) bool { return true case *IntersectionType: - // `Any` is never a subtype of a intersection type - switch subType { - case AnyResourceType, AnyStructType, AnyType: - return false - } - switch typedSubType := subType.(type) { case *IntersectionType: diff --git a/runtime/sema/type_tags.go b/runtime/sema/type_tags.go index 9a53c8f6ae..bef99a388e 100644 --- a/runtime/sema/type_tags.go +++ b/runtime/sema/type_tags.go @@ -927,24 +927,15 @@ func commonSuperTypeOfComposites(types []Type) Type { } } - var superType Type - if hasResources { - superType = AnyResourceType - } else { - superType = AnyStructType - } - if hasCommonInterface { - if len(commonInterfacesList) == 0 { - panic(errors.NewUnreachableError()) - } - return &IntersectionType{ Types: commonInterfacesList, } + } else if hasResources { + return AnyResourceType + } else { + return AnyStructType } - - return superType } func unwrapOptionals(types []Type) ([]Type, int) {