diff --git a/BeefLibs/corlib/src/String.bf b/BeefLibs/corlib/src/String.bf index e405018e..586e72df 100644 --- a/BeefLibs/corlib/src/String.bf +++ b/BeefLibs/corlib/src/String.bf @@ -7,6 +7,7 @@ using System.Collections; using System.Diagnostics; using System.Text; using System.Threading; +using System.Interop; using System; namespace System @@ -2450,6 +2451,16 @@ namespace System buf } + [Comptime(ConstEval=true)] + public Span ToConstNativeW() + { + int encodedLen = UTF16.GetEncodedLen(this); + var buf = new char16[encodedLen + 1]* ( ? ); + UTF16.Encode(this, buf, encodedLen); + buf[encodedLen] = 0; + return .(buf, encodedLen + 1); + } + public static bool Equals(char8* str1, char8* str2) { for (int i = 0; true; i++) diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index ed3d3707..e4e5865c 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -2636,6 +2636,8 @@ bool BfMethodMatcher::CheckType(BfTypeInstance* typeInstance, BfTypedValue targe if (isResolvingVarField) { + BF_ASSERT(mModule->mBfIRBuilder->mIgnoreWrites); + // Don't even consider - we can't do method calls on ourselves when we are resolving var fields, because // we are not allowed to generate methods when our field types are unknown. We may fix this in the future, // but currently it breaks out expected order of operations. One issue is that our call signatures change diff --git a/IDEHelper/Compiler/CeMachine.cpp b/IDEHelper/Compiler/CeMachine.cpp index de1089cc..7886128e 100644 --- a/IDEHelper/Compiler/CeMachine.cpp +++ b/IDEHelper/Compiler/CeMachine.cpp @@ -4195,8 +4195,9 @@ BfTypedValue CeContext::Call(BfAstNode* targetSrc, BfModule* module, BfMethodIns SetAndRestoreValue prevCallerActiveTypeDef(mCallerActiveTypeDef, module->GetActiveTypeDef()); SetAndRestoreValue prevExpectingType(mCurExpectingType, expectingType); + SetAndRestoreValue prevCtxResolvingVar(module->mContext->mResolvingVarField, false); SetAndRestoreValue moduleCurMethodInstance(module->mCurMethodInstance, methodInstance); - SetAndRestoreValue moduleCurTypeInstance(module->mCurTypeInstance, methodInstance->GetOwner()); + SetAndRestoreValue moduleCurTypeInstance(module->mCurTypeInstance, methodInstance->GetOwner()); SetAndRestoreValue prevCurExecuteId(mCurModule->mCompiler->mCurCEExecuteId, mCeMachine->mExecuteId); @@ -4561,7 +4562,7 @@ BfTypedValue CeContext::Call(BfAstNode* targetSrc, BfModule* module, BfMethodIns else if ((retInstAddr != 0) || (allocThisInstAddr != 0)) { auto* retPtr = memStart + retInstAddr; - if (allocThisInstAddr != 0) + if ((allocThisInstAddr != 0) && (methodInstance->mMethodDef->mMethodType == BfMethodType_Ctor)) { retPtr = memStart + allocThisAddr; returnType = thisType;