Skip to content

Commit db8b848

Browse files
authored
Merge pull request #83869 from hamishknight/carousel
[Sema] Resolve interface type in `ExtendedTypeRequest`
2 parents fdb1f93 + 0c16c00 commit db8b848

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3028,7 +3028,7 @@ ExtendedTypeRequest::evaluate(Evaluator &eval, ExtensionDecl *ext) const {
30283028
TypeResolutionOptions options(TypeResolverContext::ExtensionBinding);
30293029
if (ext->isInSpecializeExtensionContext())
30303030
options |= TypeResolutionFlags::AllowUsableFromInline;
3031-
const auto resolution = TypeResolution::forStructural(
3031+
const auto resolution = TypeResolution::forInterface(
30323032
ext->getDeclContext(), options, nullptr,
30333033
// FIXME: Don't let placeholder types escape type resolution.
30343034
// For now, just return the placeholder type.

test/Constraints/patterns.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -592,16 +592,16 @@ func f60503() {
592592
}
593593

594594
// rdar://105089074
595-
enum EWithIdent<Id> where Id: P { // expected-note 2 {{where 'Id' = 'Int'}}
595+
enum EWithIdent<Id> where Id: P {
596596
case test(Id)
597597
}
598598

599-
extension [EWithIdent<Int>] {
599+
extension [EWithIdent<Int>] { // expected-error {{type 'Int' does not conform to protocol 'P'}}
600600
func test() {
601601
sorted { lhs, rhs in
602602
switch (rhs, rhs) {
603603
case let (.test(x), .test(y)): break
604-
// expected-error@-1 2 {{generic enum 'EWithIdent' requires that 'Int' conform to 'P'}}
604+
// expected-error@-1 2 {{type 'Element' has no member 'test'}}
605605
case (_, _): break
606606
}
607607
}

test/decl/ext/generic.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,3 +230,24 @@ extension (NewGeneric) {
230230
return NewGeneric()
231231
}
232232
}
233+
234+
protocol P7 {}
235+
extension Float: P7 {}
236+
237+
protocol Q1 {
238+
associatedtype X
239+
func foo(_ x: X)
240+
}
241+
struct S7<T: P7>: Q1 {
242+
func foo(_ x: T) {}
243+
}
244+
245+
// Make sure we reject these extensions.
246+
extension S7<Int> {} // expected-error {{type 'Int' does not conform to protocol 'P7'}}
247+
extension [S7<Int>] {} // expected-error {{type 'Int' does not conform to protocol 'P7'}}
248+
extension Array<S7<Int>> {} // expected-error {{type 'Int' does not conform to protocol 'P7'}}
249+
extension S7<Int>? {} // expected-error {{type 'Int' does not conform to protocol 'P7'}}
250+
extension S7<Int>.X {} // expected-error {{type 'Int' does not conform to protocol 'P7'}}
251+
extension S7<Float>.X {} // expected-error {{extension of type 'S7<Float>.X' (aka 'Float') must be declared as an extension of 'Float'}}
252+
// expected-note@-1 {{did you mean to extend 'Float' instead?}}
253+
extension S7<T> {} // expected-error {{cannot find type 'T' in scope}}

validation-test/compiler_crashers_2/28db756e678d736.swift renamed to validation-test/compiler_crashers_2_fixed/28db756e678d736.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// {"kind":"emit-silgen","signature":"swift::Lowering::SILGenModule::useConformance(swift::ProtocolConformanceRef)"}
2-
// RUN: not --crash %target-swift-frontend -emit-silgen %s
2+
// RUN: not %target-swift-frontend -emit-silgen %s
33
protocol a {
44
}
55
struct b<c: a> {

0 commit comments

Comments
 (0)