Skip to content

Commit 95843e3

Browse files
committed
ClangImporter: Remove ConstantConvertKind::{Coerce,Downcast}
1 parent 2cfc459 commit 95843e3

File tree

3 files changed

+10
-23
lines changed

3 files changed

+10
-23
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3381,7 +3381,7 @@ namespace {
33813381
// Create the global constant.
33823382
auto result = Impl.createConstant(name, dc, type,
33833383
clang::APValue(decl->getInitVal()),
3384-
ConstantConvertKind::Coerce,
3384+
ConstantConvertKind::None,
33853385
/*static*/dc->isTypeContext(), decl);
33863386
Impl.ImportedDecls[{decl->getCanonicalDecl(), getVersion()}] = result;
33873387

@@ -8285,16 +8285,6 @@ ClangImporter::Implementation::createConstant(Identifier name, DeclContext *dc,
82858285
expr = new (C) ForceValueExpr(expr, SourceLoc());
82868286
break;
82878287
}
8288-
8289-
case ConstantConvertKind::Coerce:
8290-
break;
8291-
8292-
case ConstantConvertKind::Downcast: {
8293-
expr = new (C) ForcedCheckedCastExpr(expr, SourceLoc(), SourceLoc(),
8294-
TypeLoc::withoutLoc(type));
8295-
expr->setImplicit();
8296-
break;
8297-
}
82988288
}
82998289

83008290
// Create the return statement.

lib/ClangImporter/ImportMacro.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static ValueDecl *importNumericLiteral(ClangImporter::Implementation &Impl,
125125

126126
return createMacroConstant(Impl, MI, name, DC, constantType,
127127
clang::APValue(value),
128-
ConstantConvertKind::Coerce,
128+
ConstantConvertKind::None,
129129
/*static*/ false, ClangN);
130130
}
131131

@@ -143,7 +143,7 @@ static ValueDecl *importNumericLiteral(ClangImporter::Implementation &Impl,
143143

144144
return createMacroConstant(Impl, MI, name, DC, constantType,
145145
clang::APValue(value),
146-
ConstantConvertKind::Coerce,
146+
ConstantConvertKind::None,
147147
/*static*/ false, ClangN);
148148
}
149149
// TODO: Other numeric literals (complex, imaginary, etc.)
@@ -186,7 +186,7 @@ static ValueDecl *importStringLiteral(ClangImporter::Implementation &Impl,
186186
return nullptr;
187187

188188
return Impl.createConstant(name, DC, importTy, parsed->getString(),
189-
ConstantConvertKind::Coerce, /*static*/ false,
189+
ConstantConvertKind::None, /*static*/ false,
190190
ClangN);
191191
}
192192

@@ -598,7 +598,7 @@ static ValueDecl *importMacro(ClangImporter::Implementation &impl,
598598

599599
return createMacroConstant(impl, macro, name, DC, resultSwiftType,
600600
clang::APValue(resultValue),
601-
ConstantConvertKind::Coerce,
601+
ConstantConvertKind::None,
602602
/*isStatic=*/false, ClangN);
603603
}
604604
case 4: {

lib/ClangImporter/ImporterImpl.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,12 @@ class ValueDecl;
8686
enum class ConstantConvertKind {
8787
/// No conversion required.
8888
None,
89-
/// Coerce the constant to the given type.
90-
Coerce,
91-
/// Construct the given type from the constant value.
89+
/// Construct the given type from the constant value by calling
90+
/// init(rawValue:).
9291
Construction,
93-
/// Construct the given type from the constant value, using an
94-
/// optional initializer.
95-
ConstructionWithUnwrap,
96-
/// Perform an unchecked downcast to the given type.
97-
Downcast
92+
/// Construct the given type from the constant value by force
93+
/// unwrapping the result of init(rawValue:).
94+
ConstructionWithUnwrap
9895
};
9996

10097
/// Describes the kind of type import we're performing.

0 commit comments

Comments
 (0)