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
4 changes: 4 additions & 0 deletions include/swift/AST/DiagnosticsSIL.def
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ ERROR(global_must_be_compile_time_const,none,
"global variable must be a compile-time constant", ())
ERROR(non_final_generic_class_function,none,
"classes cannot have non-final generic fuctions in embedded Swift", ())
ERROR(embedded_swift_existential_type,none,
"cannot use a value of protocol type %0 in embedded Swift", (Type))
ERROR(embedded_swift_existential,none,
"cannot use a value of protocol type in embedded Swift", ())
NOTE(performance_called_from,none,
"called from here", ())

Expand Down
6 changes: 5 additions & 1 deletion lib/SILOptimizer/Mandatory/PerformanceDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,11 @@ bool PerformanceDiagnostics::visitInst(SILInstruction *inst,
if (module.getOptions().EmbeddedSwift &&
impact & RuntimeEffect::Existential) {
PrettyStackTracePerformanceDiagnostics stackTrace("existential", inst);
diagnose(loc, diag::performance_metadata, "existential");
if (impactType) {
diagnose(loc, diag::embedded_swift_existential_type, impactType.getASTType());
} else {
diagnose(loc, diag::embedded_swift_existential);
}
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion test/embedded/anyobject-error-no-stdlib.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public typealias AnyObject = Builtin.AnyObject
precedencegroup AssignmentPrecedence { assignment: true }

public func foo(_ x: AnyObject) {
_ = type(of: x) // expected-error {{existential can cause metadata allocation or locks}}
_ = type(of: x) // expected-error {{cannot use a value of protocol type 'AnyObject' in embedded Swift}}
// expected-note@-1 {{called from here}}
}
2 changes: 1 addition & 1 deletion test/embedded/basic-errors-no-stdlib.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ public protocol Player {}
struct Concrete: Player {}

public func test() -> any Player {
Concrete() // expected-error {{existential can cause metadata allocation or locks}}
Concrete() // expected-error {{cannot use a value of protocol type 'any Player' in embedded Swift}}
// expected-note@-1 {{called from here}}
}
2 changes: 1 addition & 1 deletion test/embedded/throw-trap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public func catching1() {
}
}

// CHECK-EXISTENTIALS: error: existential can cause metadata allocation or locks
// CHECK-EXISTENTIALS: error: cannot use a value of protocol type 'any Error' in embedded Swift

// CHECK-TRAPS-SIL: sil @$s4main9throwing1SiyKF : $@convention(thin) () -> (Int, @error any Error) {
// CHECK-TRAPS-SIL-NEXT: bb0:
Expand Down