@@ -361,19 +361,29 @@ ParserStatus Parser::parseGenericWhereClause(
361
361
SecondType = makeParserResult (ErrorTypeRepr::create (Context, PreviousLoc));
362
362
363
363
// Add the requirement
364
+ //
365
+ // If the a type has a code completion token, don't record a same
366
+ // type constraint, because otherwise if we have
367
+ // K.#^COMPLETE^# == Foo
368
+ // we parse this as
369
+ // K == Foo
370
+ // and thus simplify K to Foo. But we didn't want to state that K is Foo
371
+ // but that K has a member of type Foo.
372
+ // FIXME: The proper way to fix this would be to represent the code
373
+ // completion token in the TypeRepr.
364
374
if (FirstType.hasCodeCompletion ()) {
365
- // If the first type has a code completion token, don't record a same
366
- // type constraint because otherwise if we have
367
- // K.#^COMPLETE^# == Foo
368
- // we parse this as
369
- // K == Foo
370
- // and thus simplify K to Foo. But we didn't want to state that K is Foo
371
- // but that K has a member of type Foo.
372
- // FIXME: The proper way to fix this would be to represent the code
373
- // completion token in the TypeRepr.
375
+ SecondType = makeParserResult (
376
+ SecondType,
377
+ ErrorTypeRepr::create (Context, SecondType.get ()->getLoc ()));
378
+ }
379
+ if (SecondType.hasCodeCompletion ()) {
380
+ FirstType = makeParserResult (
381
+ FirstType,
382
+ ErrorTypeRepr::create (Context, FirstType.get ()->getLoc ()));
383
+ }
384
+ if (FirstType.hasCodeCompletion () || SecondType.hasCodeCompletion ()) {
374
385
Requirements.push_back (RequirementRepr::getTypeConstraint (
375
- FirstType.get (), EqualLoc,
376
- ErrorTypeRepr::create (Context, SecondType.get ()->getLoc ()),
386
+ FirstType.get (), EqualLoc, SecondType.get (),
377
387
isRequirementExpansion));
378
388
} else {
379
389
Requirements.push_back (RequirementRepr::getSameType (
0 commit comments