Skip to content

Commit 515715b

Browse files
authored
Merge pull request #62646 from DougGregor/global-actor-formal-metatype
2 parents cfe49a0 + 0e8d4c4 commit 515715b

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

lib/SILGen/SILGenPoly.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ ManagedValue Transform::transform(ManagedValue v,
521521
} else if (inputSubstType->isSet()) {
522522
fn = SGF.SGM.getSetUpCast(Loc);
523523
} else {
524-
llvm_unreachable("unsupported collection upcast kind");
524+
llvm::report_fatal_error("unsupported collection upcast kind");
525525
}
526526

527527
return SGF.emitCollectionConversion(Loc, fn, inputSubstType,

lib/SILGen/SILGenProlog.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -897,13 +897,13 @@ SILValue SILGenFunction::emitLoadGlobalActorExecutor(Type globalActor) {
897897
? MetatypeRepresentation::Thick
898898
: MetatypeRepresentation::Thin;
899899

900-
ManagedValue actorMetaType =
900+
CanType actorMetaType = CanMetatypeType::get(actorType, metaRepr);
901+
ManagedValue actorMetaTypeValue =
901902
ManagedValue::forUnmanaged(B.createMetatype(loc,
902-
SILType::getPrimitiveObjectType(
903-
CanMetatypeType::get(actorType, metaRepr))));
903+
SILType::getPrimitiveObjectType(actorMetaType)));
904904

905-
RValue actorInstanceRV = emitRValueForStorageLoad(loc, actorMetaType,
906-
actorType, /*isSuper*/ false, sharedInstanceDecl, PreparedArguments(),
905+
RValue actorInstanceRV = emitRValueForStorageLoad(loc, actorMetaTypeValue,
906+
actorMetaType, /*isSuper*/ false, sharedInstanceDecl, PreparedArguments(),
907907
subs, AccessSemantics::Ordinary, instanceType, SGFContext());
908908
ManagedValue actorInstance = std::move(actorInstanceRV).getScalarValue();
909909
return emitLoadActorExecutor(loc, actorInstance);

test/SILGen/Inputs/MeowActor.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
@available(SwiftStdlib 5.1, *)
22
@globalActor public final class MeowActor {
33
public static let shared = _Impl()
4-
4+
5+
public actor _Impl {
6+
nonisolated
7+
public func enqueue(_ job: UnownedJob) {
8+
// DOES NOTHING! :)
9+
}
10+
}
11+
}
12+
13+
@available(SwiftStdlib 5.1, *)
14+
@globalActor public struct HissActor {
15+
public static let shared = _Impl()
16+
517
public actor _Impl {
618
nonisolated
719
public func enqueue(_ job: UnownedJob) {

test/SILGen/global-actor.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,21 @@ import MeowActor
66
@available(SwiftStdlib 5.1, *)
77
@MeowActor func doMeow() {}
88

9+
@available(SwiftStdlib 5.1, *)
10+
@HissActor func doHiss() {}
11+
912
// RUN: %target-swift-frontend -disable-availability-checking -enable-library-evolution -emit-module -o %t/MeowActor.swiftmodule %S/Inputs/MeowActor.swift
1013
// RUN: %target-swift-frontend -disable-availability-checking -emit-silgen %s -I %t | %FileCheck --check-prefix CHECK-RESILIENT %s
1114
// CHECK-RESILIENT: metatype $@thick MeowActor.Type
15+
// CHECK-RESILIENT: metatype $@thick HissActor.Type
1216

1317
// RUN: %target-swift-frontend -disable-availability-checking -emit-module -o %t/MeowActor.swiftmodule %S/Inputs/MeowActor.swift
1418
// RUN: %target-swift-frontend -disable-availability-checking -emit-silgen %s -I %t | %FileCheck --check-prefix CHECK-FRAGILE %s
1519
// CHECK-FRAGILE: metatype $@thin MeowActor.Type
20+
// CHECK-FRAGILE: metatype $@thin HissActor.Type
1621

1722
@available(SwiftStdlib 5.1, *)
1823
func someFunc() async {
1924
await doMeow()
20-
}
25+
await doHiss()
26+
}

0 commit comments

Comments
 (0)