Skip to content

Commit 06d2a96

Browse files
committed
returns only true if no unsupported type conversion is entered
1 parent e513182 commit 06d2a96

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// This file implements semantic analysis for declarations.
1414
//
1515
//===----------------------------------------------------------------------===//
16-
16+
#include <type_traits>
1717
#include "TypeCheckDecl.h"
1818
#include "CodeSynthesis.h"
1919
#include "DerivedConformances.h"
@@ -3085,18 +3085,27 @@ bool TypeChecker::isTypeInferredByTypealias(TypeAliasDecl *typealias,
30853085
return false;
30863086
}
30873087

3088+
bool supportedInferredType = false;
30883089
for (size_t i=0; i<nominalGenericArguments.size(); i++){
30893090
auto nominalBoundGenericType = nominalGenericArguments[i];
3090-
if (auto classTy = dyn_cast<GenericTypeParamType>(nominalBoundGenericType)){
3091-
auto typealiasBoundGenericType = typealiasGenericArguments[i];
3092-
if (auto classTy = dyn_cast<StructType>(typealiasBoundGenericType)){
3093-
return true;
3094-
}
3091+
auto typealiasBoundGenericType = typealiasGenericArguments[i];
3092+
if(nominalBoundGenericType.getPointer()->getKind() == typealiasBoundGenericType.getPointer()->getKind() )
3093+
{
3094+
continue;
30953095
}
3096-
}
30973096

3097+
if (dyn_cast<GenericTypeParamType>(nominalBoundGenericType) != nullptr && dyn_cast<StructType>(typealiasBoundGenericType) != nullptr)
3098+
{
3099+
supportedInferredType = true;
3100+
}
3101+
else
3102+
{
3103+
supportedInferredType = false;
3104+
break;
3105+
}
3106+
}
30983107

3099-
return false;
3108+
return supportedInferredType;
31003109
}
31013110

31023111
Type

0 commit comments

Comments
 (0)