diff --git a/lib/SILGen/SILGenApply.cpp b/lib/SILGen/SILGenApply.cpp index 43fd0d35c70b0..85009a635d44c 100644 --- a/lib/SILGen/SILGenApply.cpp +++ b/lib/SILGen/SILGenApply.cpp @@ -1502,7 +1502,7 @@ class SILGenApply : public Lowering::ExprVisitor { SILType loweredResultTy; auto selfMetaTy = selfValue.getType().getAs(); if (selfMetaTy) { - loweredResultTy = SILType::getPrimitiveObjectType( + loweredResultTy = SGF.getLoweredLoadableType( CanMetatypeType::get(resultTy, selfMetaTy->getRepresentation())); } else { loweredResultTy = SGF.getLoweredLoadableType(resultTy); diff --git a/test/SILGen/opaque_result_type_constructor.swift b/test/SILGen/opaque_result_type_constructor.swift new file mode 100644 index 0000000000000..f87a8811979ba --- /dev/null +++ b/test/SILGen/opaque_result_type_constructor.swift @@ -0,0 +1,22 @@ +// RUN: %target-swift-emit-silgen %s + +// https://github.com/swiftlang/swift/issues/68277 + +enum E: P { + static func m() -> some Any { () } +} + +protocol P { + associatedtype A + static func m() -> A +} + +struct S { + let t: T +} + +extension S where T == E.A { + init() { + self.init(t: E.m()) + } +} diff --git a/validation-test/SILGen/SwiftUI/issue-68298.swift b/validation-test/SILGen/SwiftUI/issue-68298.swift new file mode 100644 index 0000000000000..e1b5e3e2fd5c9 --- /dev/null +++ b/validation-test/SILGen/SwiftUI/issue-68298.swift @@ -0,0 +1,34 @@ +// RUN: %target-swift-emit-silgen %s -target %target-cpu-apple-macosx11 -swift-version 5 + +// REQUIRES: objc_interop +// REQUIRES: OS=macosx + +import SwiftUI + +protocol StaticFactory { + associatedtype Result + + func callAsFunction() -> Self.Result +} + +struct ViewFactory: StaticFactory { + let systemName: String + + func callAsFunction() -> some View { + Image(systemName: systemName) + .frame(width: 20, height: 20) + } +} + +extension Button where Label == ViewFactory.Result { + init( + systemName: String, + action: @escaping () -> Void + ) { + self.init( + action: action + ) { + ViewFactory(systemName: systemName)() + } + } +} diff --git a/validation-test/compiler_crashers_fixed/issue-52841.swift b/validation-test/compiler_crashers_fixed/issue-52841.swift new file mode 100644 index 0000000000000..9b0a5ac198366 --- /dev/null +++ b/validation-test/compiler_crashers_fixed/issue-52841.swift @@ -0,0 +1,11 @@ +// RUN: %target-swift-frontend -emit-ir -g %s + +protocol Foo { + associatedtype ErrorType: Error +} + +extension Array: Error where Element: Error {} + +class Bar { + func doSomething(with result: Result) {} +} diff --git a/validation-test/compiler_crashers_fixed/issue-66572.swift b/validation-test/compiler_crashers_fixed/issue-66572.swift new file mode 100644 index 0000000000000..404865fd77fe2 --- /dev/null +++ b/validation-test/compiler_crashers_fixed/issue-66572.swift @@ -0,0 +1,12 @@ +// RUN: %target-swift-frontend -emit-ir %s + +public final class TypedNode { + public var property: String? + + public func withProperty(_ generator: (Self) -> String) -> Self { + self.property = generator(self) + return self + } +} + +let tree = TypedNode().withProperty { "\($0)" } diff --git a/validation-test/compiler_crashers_fixed/issue-66590.swift b/validation-test/compiler_crashers_fixed/issue-66590.swift new file mode 100644 index 0000000000000..0e62f1180e8bd --- /dev/null +++ b/validation-test/compiler_crashers_fixed/issue-66590.swift @@ -0,0 +1,6 @@ +// RUN: not %target-swift-frontend -typecheck %s + +struct A {} +extension A.B> { + struct B {} +}