[CS] Quick workaround for rdar://160135085

Temporarily disable the checking requirements for typealias types,
and desugar the typealias since the constraint system does not
currently correctly handle type variables in the underlying type.
This commit is contained in:
Hamish Knight
2025-09-23 14:36:06 +01:00
parent 90a5a0f87d
commit 20202f53a9
6 changed files with 56 additions and 3 deletions

View File

@@ -268,9 +268,7 @@ public:
auto substTy = TypeAliasType::get(
aliasTy->getDecl(), transform(aliasTy->getParent()), genericArgs,
transform(aliasTy->getSinglyDesugaredType()));
openGenericTypeRequirements(substTy->getDecl(),
substTy->getSubstitutionMap());
return substTy;
return substTy->getSinglyDesugaredType();
}
Type transformErrorType(ErrorType *errTy) {

View File

@@ -0,0 +1,24 @@
// RUN: %empty-directory(%t/modules)
// RUN: split-file %s %t
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/modules/A.swiftmodule -module-name A %t/a.swift
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/modules/B.swiftmodule -module-name B -I %t/modules %t/b.swift
// RUN: %target-swift-frontend -typecheck -I %t/modules %t/c.swift
//--- a.swift
public struct S<T> {
public init(_ x: T) {}
}
//--- b.swift
import A
public typealias S = A.S
//--- c.swift
import A
import B
_ = S(0)

View File

@@ -1,4 +1,5 @@
// RUN: %target-typecheck-verify-swift
// REQUIRES: rdar160135085
struct K<U> {} // expected-note 6{{'U' declared as parameter to type 'K'}}
protocol Q {}

View File

@@ -465,3 +465,19 @@ func testSugar(_ gx: GX<Int>, _ gy: GX<Int>.GY<Double>, gz: GX<Int>.GY<Double>.E
let i2: Int = gy // expected-error{{cannot convert value of type 'GX<Int>.GY<Double>' (aka 'Array<Double>') to specified type 'Int'}}
let i3: Int = gz // expected-error{{cannot convert value of type 'GX<Int>.GY<Double>.Element' (aka 'Double') to specified type 'Int'}}
}
func testLocalRequirementInference<T>(_ x: T, y: Int, s: S) {
typealias X<U: P> = (T, U) where T == U.A
func foo<V>(_ x: X<V>) {} // expected-note {{where 'V' = 'Int'}} expected-note {{where 'T' = 'T', 'V.A' = 'S.A' (aka 'Float')}}
foo((x, y)) // expected-error {{local function 'foo' requires that 'Int' conform to 'P'}}
foo((x, s)) // expected-error {{local function 'foo' requires the types 'T' and 'S.A' (aka 'Float') be equivalent}}
}
struct TestNestedRequirementInference<T> {
typealias X<U: P> = (T, U) where T == U.A
func foo<V>(_ x: X<V>) {} // expected-note {{where 'V' = 'Int'}} expected-note {{where 'T' = 'T', 'V.A' = 'S.A' (aka 'Float')}}
func bar(_ x: T, y: Int, s: S) {
foo((x, y)) // expected-error {{instance method 'foo' requires that 'Int' conform to 'P'}}
foo((x, s)) // expected-error {{instance method 'foo' requires the types 'T' and 'S.A' (aka 'Float') be equivalent}}
}
}

View File

@@ -0,0 +1,6 @@
// {"kind":"typecheck","signature":"swift::constraints::ConstraintSystem::openGenericParameters(swift::DeclContext*, swift::GenericSignature, llvm::SmallVectorImpl<std::__1::pair<swift::GenericTypeParamType*, swift::TypeVariableType*>>&, swift::constraints::ConstraintLocatorBuilder, swift::constraints::PreparedOverloadBuilder*)","signatureAssert":"Assertion failed: (sig), function openGenericParameters"}
// RUN: not %target-swift-frontend -typecheck %s
class a<b
func c -> d
typealias c : a
c

View File

@@ -0,0 +1,8 @@
// {"kind":"typecheck","original":"0df5dc82","signature":"swift::constraints::ConstraintSystem::typeVarOccursInType(swift::TypeVariableType*, swift::Type, bool*)","signatureAssert":"Assertion failed: ((!typeVariables.empty() || hasError()) && \"Did not find type variables!\"), function getTypeVariables"}
// RUN: not %target-swift-frontend -typecheck %s
struct a<each b {
typealias d<c> = (
> func 1 {
typealias e = f
e
typealias e = d