Skip to content

Commit e8c8c0b

Browse files
committed
[CSApply] Remove obsolete diagnoseInvalidDynamicConstructorReferences
1 parent 0595cef commit e8c8c0b

File tree

1 file changed

+0
-68
lines changed

1 file changed

+0
-68
lines changed

lib/Sema/CSApply.cpp

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -342,74 +342,6 @@ static bool buildObjCKeyPathString(KeyPathExpr *E,
342342
return true;
343343
}
344344

345-
/// Determine whether the given type refers to a non-final class (or
346-
/// dynamic self of one).
347-
static bool isNonFinalClass(Type type) {
348-
if (auto dynamicSelf = type->getAs<DynamicSelfType>())
349-
type = dynamicSelf->getSelfType();
350-
351-
if (auto classDecl = type->getClassOrBoundGenericClass())
352-
return !classDecl->isFinal();
353-
354-
if (auto archetype = type->getAs<ArchetypeType>())
355-
if (auto super = archetype->getSuperclass())
356-
return isNonFinalClass(super);
357-
358-
if (type->isExistentialType())
359-
return true;
360-
361-
return false;
362-
}
363-
364-
static bool
365-
diagnoseInvalidDynamicConstructorReferences(ConstraintSystem &cs,
366-
Expr *base,
367-
DeclNameLoc memberRefLoc,
368-
ConstructorDecl *ctorDecl,
369-
bool SuppressDiagnostics) {
370-
auto &tc = cs.getTypeChecker();
371-
auto baseTy = cs.getType(base)->getRValueType();
372-
auto instanceTy = baseTy->getMetatypeInstanceType();
373-
374-
bool isStaticallyDerived =
375-
base->isStaticallyDerivedMetatype(
376-
[&](const Expr *expr) -> Type {
377-
return cs.getType(expr);
378-
});
379-
380-
// FIXME: The "hasClangNode" check here is a complete hack.
381-
if (isNonFinalClass(instanceTy) &&
382-
!isStaticallyDerived &&
383-
!ctorDecl->hasClangNode() &&
384-
!(ctorDecl->isRequired() ||
385-
ctorDecl->getDeclContext()->getSelfProtocolDecl())) {
386-
if (SuppressDiagnostics)
387-
return false;
388-
389-
tc.diagnose(memberRefLoc, diag::dynamic_construct_class, instanceTy)
390-
.highlight(base->getSourceRange());
391-
auto ctor = cast<ConstructorDecl>(ctorDecl);
392-
tc.diagnose(ctorDecl, diag::note_nonrequired_initializer,
393-
ctor->isImplicit(), ctor->getFullName());
394-
// Constructors cannot be called on a protocol metatype, because there is no
395-
// metatype to witness it.
396-
} else if (isa<ConstructorDecl>(ctorDecl) &&
397-
baseTy->is<MetatypeType>() &&
398-
instanceTy->isExistentialType()) {
399-
if (SuppressDiagnostics)
400-
return false;
401-
402-
if (isStaticallyDerived) {
403-
tc.diagnose(memberRefLoc, diag::construct_protocol_by_name, instanceTy)
404-
.highlight(base->getSourceRange());
405-
} else {
406-
tc.diagnose(memberRefLoc, diag::construct_protocol_value, baseTy)
407-
.highlight(base->getSourceRange());
408-
}
409-
}
410-
return true;
411-
}
412-
413345
/// Form a type checked expression for the index of a @dynamicMemberLookup
414346
/// subscript index parameter.
415347
/// The index expression will have a tuple type of `(dynamicMember: T)`.

0 commit comments

Comments
 (0)