Skip to content

Commit 0cfa048

Browse files
committed
[Isolated conformances] Start parsing 'nonisolated' on conformances
It doesn't mean anything yet, but parse it and make sure it reproduces in the module interface.
1 parent 3837661 commit 0cfa048

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

lib/Parse/ParseType.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,15 @@ ParserResult<TypeRepr> Parser::parseTypeScalar(
413413
return makeParserCodeCompletionResult<TypeRepr>(ET);
414414
}
415415

416+
// "nonisolated" for attribute lists.
417+
if (reason == ParseTypeReason::InheritanceClause &&
418+
Tok.isContextualKeyword("nonisolated")) {
419+
SourceLoc nonisolatedLoc = consumeToken();
420+
parsedAttributeList.Attributes.push_back(
421+
TypeAttribute::createSimple(Context, TypeAttrKind::Nonisolated,
422+
SourceLoc(), nonisolatedLoc));
423+
}
424+
416425
// Parse generic parameters in SIL mode.
417426
GenericParamList *generics = nullptr;
418427
SourceLoc substitutedLoc;

lib/Sema/TypeCheckType.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3504,7 +3504,8 @@ TypeResolver::resolveAttributedType(TypeRepr *repr, TypeResolutionOptions option
35043504

35053505
if (handleInheritedOnly(claim<UncheckedTypeAttr>(attrs)) ||
35063506
handleInheritedOnly(claim<PreconcurrencyTypeAttr>(attrs)) ||
3507-
handleInheritedOnly(claim<UnsafeTypeAttr>(attrs)))
3507+
handleInheritedOnly(claim<UnsafeTypeAttr>(attrs)) ||
3508+
handleInheritedOnly(claim<NonisolatedTypeAttr>(attrs)))
35083509
return ty;
35093510

35103511
if (auto retroactiveAttr = claim<RetroactiveTypeAttr>(attrs)) {

test/ModuleInterface/isolated_conformance.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ public class MyClass { }
1414
extension MyClass: @MainActor MyProtocol {
1515
@MainActor public func f() { }
1616
}
17+
18+
extension MyClass: nonisolated Equatable {
19+
nonisolated public static func ==(lhs: MyClass, rhs: MyClass) -> Bool {
20+
false
21+
}
22+
}

0 commit comments

Comments
 (0)