Skip to content

Commit 49ee35a

Browse files
committed
Sema: Fix crash with SpecializeExpr around something that's not a type
Unfortunately the diagnostic is terrible. Fixes #74858
1 parent ca0afe2 commit 49ee35a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13978,6 +13978,8 @@ ConstraintSystem::simplifyExplicitGenericArgumentsConstraint(
1397813978
decl = bound->getDecl();
1397913979
for (auto argType : bound->getDirectGenericArgs()) {
1398013980
auto *typeVar = argType->getAs<TypeVariableType>();
13981+
if (!typeVar)
13982+
return SolutionKind::Error;
1398113983
auto *genericParam = typeVar->getImpl().getGenericParameter();
1398213984
openedTypes.push_back({genericParam, typeVar});
1398313985
}

test/Sema/issue-74858.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
func invalidSpecializeExpr(_ x: DS<Int>.Type) {
4+
let y = x<Int>.self
5+
// expected-error@-1 {{type of expression is ambiguous without a type annotation}}
6+
// FIXME: Bad diagnostic
7+
}

0 commit comments

Comments
 (0)