Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/SILGen/SILGenApply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,7 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
SILType loweredResultTy;
auto selfMetaTy = selfValue.getType().getAs<AnyMetatypeType>();
if (selfMetaTy) {
loweredResultTy = SILType::getPrimitiveObjectType(
loweredResultTy = SGF.getLoweredLoadableType(
CanMetatypeType::get(resultTy, selfMetaTy->getRepresentation()));
} else {
loweredResultTy = SGF.getLoweredLoadableType(resultTy);
Expand Down
22 changes: 22 additions & 0 deletions test/SILGen/opaque_result_type_constructor.swift
Original file line number Diff line number Diff line change
@@ -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<T> {
let t: T
}

extension S where T == E.A {
init() {
self.init(t: E.m())
}
}
34 changes: 34 additions & 0 deletions validation-test/SILGen/SwiftUI/issue-68298.swift
Original file line number Diff line number Diff line change
@@ -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)()
}
}
}
11 changes: 11 additions & 0 deletions validation-test/compiler_crashers_fixed/issue-52841.swift
Original file line number Diff line number Diff line change
@@ -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<A: Foo> {
func doSomething(with result: Result<Any, [A.ErrorType]>) {}
}
12 changes: 12 additions & 0 deletions validation-test/compiler_crashers_fixed/issue-66572.swift
Original file line number Diff line number Diff line change
@@ -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)" }
6 changes: 6 additions & 0 deletions validation-test/compiler_crashers_fixed/issue-66590.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// RUN: not %target-swift-frontend -typecheck %s

struct A<X> {}
extension A<A<Int>.B> {
struct B {}
}